package com.higold.cloud.ui.adapter

import android.text.TextPaint
import android.text.style.ClickableSpan
import android.view.View
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.higold.cloud.R
import com.higold.cloud.mvp.model.bean.Common
import com.higold.cloud.mvp.model.bean.marketList.Data
import java.text.DecimalFormat

/**
 *    author : lxz
 *    date   : 2019/8/15 16:10
 *    desc   :
 */
class MarketAdapter(data: ArrayList<Data>) : BaseQuickAdapter<Data, BaseViewHolder>(R.layout.item_market, data) {

    override fun convert(helper: BaseViewHolder, item: Data) {
        helper.setText(R.id.tv_no, "No." + (helper.adapterPosition + 1))
                .setText(R.id.tv_agent_name, item.user_name)
                .setText(R.id.tv_money, changeFloatToString(item.amount) + "W")
                .setText(R.id.tv_percent, item.tongbi_rate.toString() + "%")

        helper.getView<TextView>(R.id.tv_agent_name).isSelected = true
    }


    internal var clickableSpan: ClickableSpan = object : ClickableSpan() {
        override fun onClick(widget: View) {

        }

        override fun updateDrawState(ds: TextPaint) {

        }

    }

    private fun changeFloatToString(double: Double): String {
        val decimalFormat = DecimalFormat("##.##")
        return decimalFormat.format(double)
    }


}
